package cn.wizzer.app.task.commons.ext.quartz.job;


import cn.wizzer.app.crown.modules.services.order.CrownOrderService;
import cn.wizzer.app.sys.modules.services.SysTaskService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.quartz.Job;
import org.quartz.JobExecutionContext;


/**
 * 查询长时间没获取到的赛果的赛事，通知管理员
 *
 * @author .
 */
@IocBean
public class CrownNoResultJob implements Job {
    private static final Log log = Logs.get();

    @Inject
    @Reference
    private SysTaskService sysTaskService;


    @Inject
    @Reference(retries = 0, timeout = 500000)
    private CrownOrderService orderService;


    @Override
    public void execute(JobExecutionContext context) {
        log.info("查询长时间未获取到赛果的赛事开始");
        orderService.noResultOrder();
        log.info("查询长时间未获取到赛果的赛事结束");
        String taskId = context.getJobDetail().getKey().getName();
        sysTaskService.update(Chain.make("exeAt", (int) (System.currentTimeMillis() / 1000))
                .add("exeResult", "执行成功"), Cnd.where("id", "=", taskId));
    }
}
